package com.shiguiwu.springboot3.redis.mq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
 
@Component
public class MessageQueueService {
    
    private final ListOperations<String, Object> listOps;
    
    @Autowired
    public MessageQueueService(RedisTemplate<String, Object> redisTemplate) {
        this.listOps = redisTemplate.opsForList();
    }
    
    public void sendMessageToQueue(Object message) {
        listOps.rightPush("message_queue", message);
    }
}